//
//  UILabel+TP_Utility.m
//  E_Car
//
//  Created by 谭鹏 on 2017/7/31.
//  Copyright © 2017年 谭鹏. All rights reserved.
//

#import "UILabel+TP_Utility.h"
#import <Masonry/Masonry.h>
@implementation UILabel (TP_Utility)

+(instancetype)labelWithText:(NSString *)text Font:(UIFont *)font{
    return [[UILabel alloc]initWithText:text Font:font];
}
+(instancetype)labelWithText:(NSString *)text font:(UIFont *)font{
    return [UILabel labelWithText:text font:font color:nil];
}
+(instancetype)labelWithText:(NSString *)text font:(UIFont *)font color:(UIColor *)color {
    return [[UILabel alloc] initWithText:text font:font textColor:color textAlignment:NSTextAlignmentLeft bgColor:[UIColor clearColor] numberOfLines:0 lineBreakMode:NSLineBreakByTruncatingTail];
}

-(instancetype)initWithText:(NSString *)text Font:(UIFont *)font{
    return [self initWithText:text font:font textColor:[UIColor blackColor] textAlignment:NSTextAlignmentLeft bgColor:[UIColor whiteColor] numberOfLines:0 lineBreakMode:NSLineBreakByTruncatingTail];
}

+(instancetype)labelWithText:(NSString *)text font:(UIFont *)font textColor:(UIColor *)textColor textAlignment:(NSTextAlignment)textAlignment bgColor:(UIColor *)bgColor numberOfLines:(NSUInteger)numberOfLines lineBreakMode:(NSLineBreakMode)lineBreakMode{
    UILabel * label = [[UILabel alloc]initWithText:text font:font textColor:textColor textAlignment:textAlignment bgColor:bgColor numberOfLines:numberOfLines lineBreakMode:lineBreakMode];
    return label;
}

-(instancetype)initWithText:(NSString *)text font:(UIFont *)font textColor:(UIColor *)textColor textAlignment:(NSTextAlignment)textAlignment bgColor:(UIColor *)bgColor numberOfLines:(NSUInteger)numberOfLines lineBreakMode:(NSLineBreakMode)lineBreakMode{
    if (!text) {
        return [UILabel new];
    }else{
        self = [self init];
        if (self) {
            self.text = text;
            self.backgroundColor = bgColor;
            self.textAlignment = textAlignment;
            self.textColor = textColor;
            self.numberOfLines = numberOfLines;
            self.font = font;
            self.lineBreakMode = lineBreakMode;
            if (numberOfLines > 0) {
                [self mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.height.mas_equalTo(font.pointSize * numberOfLines).priorityLow();
                }];
            }
            
        }
        return self;
    }
    
    
    
}


@end
